package com.manor.paradise.activity

import android.content.Context
import android.content.Intent
import androidx.core.os.bundleOf
import com.blankj.utilcode.util.ActivityUtils
import com.manor.common.Constants
import com.manor.common.activity.AbsActivity
import com.manor.paradise.R
import com.mob.adsdk.WebFragment
import com.mob.gamesdk.AppGameFragment
import com.mob.gamesdk.H5GameFragment


/**
 *
 * @Project TaoMi
 * @date  2021/4/13  11:06
 * @version 1.0
 */
class WebTaskActivity :AbsActivity(){
    private val TASK_URL = "https://squirrel.kxbwmedia.com/ditch/task?union_id=10012"

    override fun getLayoutId(): Int = R.layout.activity_web_task

    companion object{
        fun forward(isGame: Boolean) {
            val bundle = bundleOf("isGame" to isGame)
            ActivityUtils.startActivity(bundle, WebTaskActivity::class.java)
        }
    }


    override fun main() {
        super.main()
        setTopTitle("现金任务")
        val isGame = intent?.extras?.getBoolean("isGame")?:false

        if (isGame){
            val fragment = AppGameFragment.newInstance()
            supportFragmentManager
                    .beginTransaction()
                    .replace(R.id.container, fragment)
                    .commitNowAllowingStateLoss()
        } else {
            val fragment = WebFragment.newInstance(TASK_URL)
            supportFragmentManager
                    .beginTransaction()
                    .replace(R.id.container, fragment)
                    .commitNowAllowingStateLoss()
        }

    }

}